package com.daoxiang.service.impl;

import com.daoxiang.dao.AdministratorMapper;
import com.daoxiang.pojo.Administrator;
import com.daoxiang.service.AdministratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class AdministratorServiceImpl implements AdministratorService {

    @Autowired
    private AdministratorMapper administratorMapper;

    @Override
    public List<Administrator> queryAdministratorByAccountAndPassword(Administrator administrator) {
        // 初始化 example 对象
        Example example = new Example(Administrator.class);
        Example.Criteria criteria = example.createCriteria();

        // 根据 maccount 和 mpassword 查询
        criteria.andEqualTo("maccount", administrator.getMaccount()).andEqualTo("mpassword", administrator.getMpassword());
        List<Administrator> administrators = this.administratorMapper.selectByExample(example);

        return administrators;
    }
}
